<?php
if(!empty($categories)) {
?>
<script type="text/javascript" src="<?php echo SITE_WEBROOT; ?>/front_end/dragdroptree/js/ajax.js"></script>
<script type="text/javascript" src="<?php echo SITE_WEBROOT; ?>/front_end/dragdroptree/js/context-menu.js"></script>
<script type="text/javascript" src="<?php echo SITE_WEBROOT; ?>/front_end/dragdroptree/js/drag-drop-folder-tree.js"></script>

<link rel="stylesheet" type="text/css" href="<?php echo SITE_WEBROOT; ?>/front_end/dragdroptree/css/drag-drop-folder-tree.css" />
<link rel="stylesheet" type="text/css" href="<?php echo SITE_WEBROOT; ?>/front_end/dragdroptree/css/context-menu.css" />

<!--
<p>
<a href="javascript:saveNodes();">Запази промените</a><br />
<br />
</p>
-->

<ul id="tree" class="dhtmlgoodies_tree">
<?php
echo $treeView->createListTree($categories);
?>
</ul>

<script language="javascript">
    window.onload=function() {
        treeObj = new JSDragDropTree();
        treeObj.setTreeId('tree');
        treeObj.setMaximumDepth(15);
        treeObj.setMessageMaximumDepthReached('Maximum depth reached');
        treeObj.setImageFolder('<?php echo SITE_WEBROOT; ?>/front_end/dragdroptree/images/');
        treeObj.initTree();
        //treeObj.expandAll();
    };
    function saveNodes() {
        save_string = treeObj.getNodeOrders();
        location.href='<?php echo SITE_WEBROOT.'admin/'; ?>/categories/save/?save_string=' + save_string;
    }
</script>
<?php
}
?>